class Singleton(type):
    """metaclass for singleton implementation

    A class will be singleton by set Singleton as its metaclass

    Example:
        >>> class Foo:
        ...     __metaclass__ = Singleton
        ...     pass
        ... 
        >>> f1 = Foo()
        >>> f2 = Foo()
        >>> f1 is f2
        True
    """
    def __call__(cls, *args, **kwargs):
        if not hasattr(cls, 'instance'):
            cls.instance = super(Singleton, cls).__call__(*args, **kwargs)

        return cls.instance

